package 竞赛.NO_400;

import java.util.Arrays;

/**
 * 100311.无需开会的工作日
 * 创建时间： 2024-06-02 10:36
 **/
public class 无需开会的工作日_100311 {
    static class Solution {
        public int countDays(int days, int[][] meetings) {
            int ans = days;
            int cur = 0;
            Arrays.sort(meetings, (a, b) -> a[0] - b[0]);
            for (int[] m : meetings) {
                if (m[0] <= cur && m[1] >= cur) {
                    ans -= (m[1] - cur);
                } else if (cur < m[0]) {
                    ans -= (m[1] - m[0] + 1);
                } else {
                    continue;
                }
                cur = m[1];
            }
            return ans;
        }
    }
}
